<template>
    <div class="container">
        <div class="containerEart">
            <p class="dialogTitle">处置要点分析</p>
            <div class="header">
                <div class="icon">
                    <svg-icon class-name="error-icon" icon-class="error" style="margin-right:10px" v-if="showIcon" />
                    <span>{{ titleOption }}</span>
                </div>
            </div>
        </div>
        <el-row :gutter="30">
            <el-col :span="21">
                <p style="margin: 10px 0;"><span
                        @click="handleDownloadPort({ attachId: fileNoticeId, attachName: fileNoticeName })"
                        style="cursor: pointer;color:#107ce5">{{
                            fileNoticeName }}</span></p>
            </el-col>
            <el-col :span="3">
                <p style="color:#107ce5;margin: 10px 0;">
                    <reportResult type="2"></reportResult>
                </p>
            </el-col>
        </el-row>
        <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
                <el-button type="primary" @click="handleUpload">
                    <svg-icon class-name="upload-icon" icon-class="upload" /><span style="margin-left:10px">本地上传</span>
                </el-button>
            </el-col>
            <!-- <el-col :span="1.5">
                <el-button type="primary" @click="handleSubmit" :disabled="multiple">
                    <svg-icon class-name="submit-icon" icon-class="submit" /><span style="margin-left:10px">提交</span>
                </el-button>
            </el-col> -->
            <!-- <el-col :span="1.5">
                <el-button type="primary" icon="Delete" :disabled="multiple" @click="handleDelete">删除</el-button>
            </el-col> -->
            <el-col :span="1.5">
                <el-button type="primary" icon="Search" @click="handleSearch">查询</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="Edit" @click="handleTag(1)">标签管理</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="Edit" @click="handleSubTag(1)">子标签管理</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="Tickets" @click="handlePreplan">地震应急预案</el-button>
            </el-col>
        </el-row>

        <el-table v-loading="loading" :data="dataList" stripe @selection-change="handleSelectionChange" row-key="dmId">
            <el-table-column type="selection" width="55" align="center" :reserve-selection="true" />
            <el-table-column label="标签" align="center" prop="dmLabel" />
            <el-table-column label="子标签" align="center" prop="dmSubtitle" />
            <el-table-column label="处置要点类型" align="center" prop="dmType" />
            <el-table-column label="管理员" align="center" prop="admin" />
            <el-table-column label="上传时间" align="center" prop="uploadTime" />
            <el-table-column label="活动名称" align="center" prop="iaName" />
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                <template #default="scope">
                    <el-button type="text" @click="handleEdit(scope.row)">修改</el-button>
                    <el-button type="text" @click="handleDelete(scope.row)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>

        <pagination v-show="total > 0" :total="total" v-model:page="queryParams.page" v-model:limit="queryParams.rows"
            @pagination="getList" />

        <div>
            <p style="font-size: 16px;font-weight: bold;">地震危险性评估功能说明</p>
            <ul class="ulList">
                <li>【成果上传】：从本地上传成果至系统中</li>
                <li>【处置要点查询】：从处置要点管理库查询处置要点并使用，可根据实际情况进行修改。</li>
                <li>所有评估完成后，需返回评估任务界面通过【报告管理】进行报告生成、上传提交等操作。</li>
            </ul>
        </div>

        <el-dialog title="处置要点管理" v-model="open" width="600px" top="200px" append-to-body>
            <el-form ref="czydRef" label-width="120px" :model="form" :rules="rules">
                <el-row style="margin: 20px 0;">
                    <el-col :span="24">
                        <el-form-item label="处置要点类型" prop="dmType">
                            <el-select v-model="form.dmType" placeholder="请选择处置要点类型" clearable :disabled="isDetail">
                                <el-option v-for="item in optionType" :key="item.value" :label="item.label"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="14.5">
                        <el-form-item label="标签" prop="dmLabel">
                            <el-input v-model="form.dmLabel" placeholder="请选择标签" :readonly="true" clearable  @click="handleTag">
                                <template #suffix>
                                    <el-icon class="el-input__icon">
                                        <Plus />
                                    </el-icon>
                                </template>
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="14.5">
                        <el-form-item label="子标签" prop="dmSubtitle">
                            <el-input v-model="form.dmSubtitle" placeholder="请选择标签" :readonly="true" clearable @click="handleSubTag">
                                <template #suffix>
                                    <el-icon class="el-input__icon">
                                        <Plus />
                                    </el-icon>
                                </template>
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="灾害风险点" prop="disasterRisk">
                            <el-input v-model="form.disasterRisk" type="textarea" maxlength="1000" show-word-limit
                                :autosize="{ minRows: 5, maxRows: 5 }" placeholder="请输入灾害风险点" :readonly="isDetail" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="处置要点" prop="disposalPoint">
                            <el-input v-model="form.disposalPoint" type="textarea" maxlength="1000" show-word-limit
                                :autosize="{ minRows: 5, maxRows: 5 }" placeholder="请输入处置要点" :readonly="isDetail" />
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <template #footer>
                <div class="dialog-footer">
                    <el-button type="primary" @click="submitForm">保 存</el-button>
                    <el-button @click="open = false">取 消</el-button>
                </div>
            </template>
        </el-dialog>

        <el-dialog title="标签管理" v-model="openTagManage" width="600px" append-to-body>
            <el-row style="margin: 20px 0;">
                <el-col :span="16">
                    <el-input v-model="formData.label" type="text" placeholder="请输入标签" clearable />
                </el-col>
                <el-col :span="8">
                    <el-button type="primary" @click="getTag" style="margin-left:15px">搜索</el-button>
                    <el-button type="primary" @click="resetTag">重置</el-button>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="16">
                    <el-input v-model="dmLabel" type="text" placeholder="请输入标签" clearable />
                </el-col>
                <el-col :span="8">
                    <el-button type="primary" @click="handleAddTag" :disabled="!dmLabel" style="margin-left:15px">添加
                    </el-button>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-table v-loading="loading" ref="tagRef" :data="tagList" stripe style="margin-top:20px" @select="selectTag" @selection-change="selectionChange" @select-all="onSelectAll" row-key="id">
                        <el-table-column type="selection" width="55" align="center" :reserve-selection="true" v-if="!isGl"/>
                        <el-table-column label="标签" align="center" prop="label" />
                        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                            <template #default="scope">
                                <el-button @click="confirmSelect" style="width: 20px;height: 30px;font-size: 14px;" v-if="!isGl" :disabled="!tagLable">确 定</el-button>
                                <el-button type="text" @click="deleteTag(scope.row)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <pagination :total="total3"  v-show="total3 > 0" v-model:page="formData.page" v-model:limit="formData.rows"
                        @pagination="getTag" />
                </el-col>
            </el-row>
            <template #footer>
                <div class="dialog-footer">
                    <el-button @click="confirmSelect" style="width: 20px;height: 30px;font-size: 14px;" v-if="!isGl" :disabled="!tagLable">确 定</el-button>
                    <el-button @click="cancelTag" style="width: 20px;height: 30px;font-size: 14px;">关 闭</el-button>
                </div>
            </template>
        </el-dialog>

        <el-dialog title="子标签管理" v-model="openSubTagManage" width="600px" append-to-body>
            <el-row style="margin: 20px 0;">
                <el-col :span="16">
                    <el-input v-model="formData1.subtitle" type="text" placeholder="请输入子标签" clearable />
                </el-col>
                <el-col :span="8">
                    <el-button type="primary" @click="getSubTag" style="margin-left:15px">搜索</el-button>
                    <el-button type="primary" @click="resetSubTag">重置</el-button>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="16">
                    <el-input v-model="dmSubLabel" type="text" placeholder="请输入子标签" clearable />
                </el-col>
                <el-col :span="8">
                    <el-button type="primary" @click="handleAddSubTag" :disabled="!dmSubLabel" style="margin-left:15px">
                        添加</el-button>
                </el-col>
            </el-row>
            <el-row>    
                <el-col :span="24">
                    <el-table v-loading="loading" ref="tagSubRef" :data="subTagList" stripe style="margin-top:20px"  @select="selectSub" @selection-change="selectionChangeSub" @select-all="onSelectAllSub" row-key="id">
                        <el-table-column type="selection" width="55" align="center" :reserve-selection="true" v-if="!isSubGl"/>
                        <el-table-column label="子标签" align="center" prop="subtitle" />
                        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                            <template #default="scope">
                                <el-button type="text" @click="deleteSubTag(scope.row)">删除</el-button>
                            </template>
                        </el-table-column>
                        <pagination :total="total4"  v-show="total4 > 0" v-model:page="formData1.page" v-model:limit="formData1.rows"
                        @pagination="getSubTag" />
                    </el-table>
                </el-col>
            </el-row>
            <template #footer>
                <div class="dialog-footer">
                    <el-button @click="confirmSubSelect" style="width: 20px;height: 30px;font-size: 14px;" v-if="!isSubGl" :disabled="!subTagLable">确 定</el-button>
                    <el-button @click="cancelSubTag" style="width: 20px;height: 30px;font-size: 14px;">关 闭</el-button>
                </div>
            </template>
        </el-dialog>

        <el-dialog title="处置要点查询" v-model="openSearch" width="900px" append-to-body>
            <h2 style="text-align: center; color: #0e76d7">
                处置要点查询
            </h2>
            <el-form :model="queryParamsSearch" ref="queryRef" :inline="true" label-width="100px">
                <el-form-item label="处置要点类型" prop="dmType">
                    <el-select v-model="queryParamsSearch.dmType" placeholder="请选择处置要点类型" clearable>
                        <el-option v-for="item in optionType" :key="item.value" :label="item.label" :value="item.value">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="标签" prop="dmLabel">
                    <el-input v-model="queryParamsSearch.dmLabel" placeholder="请输入标签" clearable />
                </el-form-item>
                <el-form-item label="子标签" prop="dmSubtitle">
                    <el-input v-model="queryParamsSearch.dmSubtitle" placeholder="请输入子标签" clearable />
                </el-form-item>
                <el-form-item label="活动名称" prop="iaName">
                    <el-input v-model="queryParamsSearch.iaName" placeholder="请输入活动名称" clearable />
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="handleQuery">搜索</el-button>
                    <el-button @click="resetQuery">重置</el-button>
                </el-form-item>

                <el-table :data="dataSearchList" stripe @selection-change="handleSelectionChange1" ref="selectDm"
                    row-key="dmId">
                    <el-table-column type="selection" width="55" align="center" :reserve-selection="true" />
                    <el-table-column label="标签" align="center" prop="dmLabel" />
                    <el-table-column label="子标签" align="center" prop="dmSubtitle" />
                    <el-table-column label="处置要点类型" align="center" prop="dmType" />
                    <el-table-column label="管理员" align="center" prop="admin" />
                    <el-table-column label="上传时间" align="center" prop="uploadTime" />
                    <el-table-column label="活动名称" align="center" prop="iaName" />
                    <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                        <template #default="scope">
                            <el-button type="text" @click="handleView(scope.row)">查看</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </el-form>
            <pagination v-show="total > 0" :total="total1" v-model:page="queryParamsSearch.page"
                v-model:limit="queryParamsSearch.rows" @pagination="getListSearch" />
            <template #footer>
                <div class="dialog-footer">
                    <el-button type="primary" :disabled="multiple1" @click="select">选择</el-button>
                </div>
            </template>
        </el-dialog>


        <el-dialog title="地震应急预案" v-model="openPre" width="800px" append-to-body>
            <p class="mt15"></p>
            <el-form :model="queryParams1" ref="queryRef1" label-width="130px">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="编码" prop="jepCode">
                            <el-input v-model="queryParams1.jepCode" placeholder="请输入编码" clearable />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="预案单位" prop="unitname">
                            <el-input v-model="queryParams1.unitname" placeholder="请输入预案单位" clearable />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="指挥部成员" prop="member">
                            <el-input v-model="queryParams1.member" placeholder="请输入指挥部成员" clearable />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="应急预案备案部门" prop="record">
                            <el-input v-model="queryParams1.record" placeholder="请输入应急预案备案部门" clearable />
                        </el-form-item>
                    </el-col>
                    <el-col :span="24" style="text-align: center;">
                        <el-button type="primary" @click="handleQuery1">查询</el-button>
                        <el-button @click="resetQuery1">重置</el-button>
                    </el-col>
                </el-row>
            </el-form>
            <el-divider border-style="dashed" />
            <template v-if="dataList1.length==0">
                <el-empty description="暂无数据" />
            </template>
            <template v-else>
                <el-form :model="dataList1[queryParams1.page]" ref="queryRef1" label-width="130px">
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="编码">
                                <span>{{ dataList1[queryParams1.page-1].jepCode
                                 }}</span>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="预案单位">
                                <span>{{ dataList1[queryParams1.page-1].unitname }}</span>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="指挥部成员">
                                <span>{{ dataList1[queryParams1.page-1].member }}</span>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="应急预案备案部门">
                                <span>{{ dataList1[queryParams1.page-1].record }}</span>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <span style="color:#606266 ;font-size: 14px;font-family: Helvetica;font-weight: bold;">正文：</span>
                            <span>{{ dataList1[queryParams1.page-1].outline }}</span>
                        </el-col>
                    </el-row>
                </el-form>
            </template>
            <div style="height:36px;margin-top: 15px;">
                <el-pagination style="float: right;" background prev-text="上一页" next-text="下一页" v-model:current-page="queryParams1.page" :page-size="1" layout="prev, pager, next" :total="dataList1.length" @current-change="handleCurrentChange"/>
            </div>
            <template #footer>
                <div class="dialog-footer">
                    <el-button @click="openPre=false" style="width: 60px;height: 32px;font-size: 14px;">关 闭</el-button>
                    <el-button @click="handleDowonPre" type="primary" style="width: 60px;height: 32px;font-size: 14px;" v-if="dataList1.length">下 载</el-button>
                </div>
            </template>
        </el-dialog>

        <!-- 商会对话框 -->
        <el-dialog v-model="showOption" width="400px" title="震情趋势" :close-on-click-modal="false" append-to-body>
            <p class="worrning">震情趋势已发生变化，请注意！</p>
            <el-radio v-model="radioOption" label="true" style="margin-left:10px">今日不再提醒</el-radio>
            <template #footer>
                <div class="dialog-footer">
                    <el-button type="primary" :disabled="!radioOption" @click="ok">确定</el-button>
                    <el-button @click="cancelOption">取消</el-button>
                </div>
            </template>
        </el-dialog>
    </div>
</template>
<script setup name="pointsAnalysis">
import { getAllList, getAllTag, getAllSubTag, saveTag, delTag, saveSubTag, delSubTag, saveDisposeManager, delDisposeManager, getDisposeManager } from "@/api/auxiliaryMeasures/disposalPoint.js";
import { getAllPointList, submitPoint, saveDisposeList, updateDisposeFX,getPreData,dowonexport } from "@/api/auxiliaryMeasures/pointsAnalysis"
import { setcookieTimeFun, getCookieFun } from "@/utils/popout"
import reportResult from "@/components/reportResult/index.vue"
import { getImport } from "@/api/business/activities";

const { proxy } = getCurrentInstance();
const showOption = ref(false);
const titleOption = ref();
const route = useRoute();
const showIcon = ref(false);
const dataList = ref([]);
const dataSearchList = ref([]);
const tagList = ref([]);
const subTagList = ref([]);
const ids = ref();
const ids1 = ref();
const loading = ref(false);
const loading1 = ref(false);
const single = ref(true);
const multiple = ref(true);
const single1 = ref(true);
const multiple1 = ref(true);
const total = ref(0);
const total1 = ref(0);
const optionType = [{ label: '物资储备', value: '物资储备' }, { label: '房屋破坏', value: '房屋破坏' }, { label: '地震灾害', value: '地震灾害' }, { label: '应急疏散', value: '应急疏散' }, { label: '其他', value: '其他' }];
const open = ref(false);
const openTag = ref(false);
const openSubTag = ref(false);
const openSearch = ref(false);
const isAdd = ref(true);
const isDetail = ref(false);
const tagId = ref();
const tagFormId = ref();
const tagLable = ref();
const subTagId = ref();
const subTagFormId = ref();
const subTagLable = ref();

const dmLabel = ref();
const dmSubLabel = ref();

const openTagManage = ref(false);
const openSubTagManage = ref(false);
const radioOption = ref(false);

const openPre = ref(false); // 预案开关
const dataList1 = ref([{label:'1'},{label:'2'},{label:'3'},{label:'4'},{label:'5'},{label:'6'},{label:'7'},{label:'8'},{label:'9'},{label:'10'},{label:'11'},{label:'12'}]);
const total2 = ref(0);
// 文件通知 信息
const fileNoticeName = ref();
const fileNoticeId = ref();
const data = reactive({
    queryParams: {
        page: 1,
        rows: 10,
        // id: 'a46bab0a9eb746cc88a39dde84ebb513',
        id: route.query.id,
    },
    queryParams1: {
        page: 1,
        jepCode: undefined,
        unitname: undefined,
        record: undefined,
        member: undefined,
    },
    queryParamsSearch: {
        page: 1,
        rows: 10,
        dmType: undefined,
        dmLabel: undefined,
        dmSubtitle: undefined,
        iaName: undefined,
    },
    form: {
        dmType: undefined,
        dmLabel: undefined,
        dmSubtitle: undefined,
        disasterRisk: undefined,
        disposalPoint: undefined,
    },
    rules: {
        dmType: [{ required: true, message: "处置要点类型不能为空", trigger: "change" }],
        dmLabel: [{ required: true, message: "标签不能为空", trigger: "change" }],
        disasterRisk: [{ required: true, message: "灾害风险点不能为空", trigger: "blur" }],
        disposalPoint: [{ required: true, message: "处置要点不能为空", trigger: "blur" }],
    }
})
const { queryParams,queryParams1, queryParamsSearch, form, rules } = toRefs(data)

/** 获取列表操作 */
function getList() {
    loading.value = true;
    getAllPointList(queryParams.value).then((response) => {
        dataList.value = response.data.map.disposeManagers;
        total.value = response.data.map.total;
        // titleOption.value = response.data.iaOpinion;
        // showIcon.value = Boolean(Number(response.data.iaOpinionStatus));
        loading.value = false;
    });
}

/** 搜索按钮操作 */
function handleQuery() {
    console.log('111');
    queryParamsSearch.value.page = 1;
    getListSearch();
}

/** 重置按钮操作 */
function resetQuery() {
    dataSearchList.value = [];
    proxy.resetForm("queryRef");
    handleQuery();
}

/** 查询数据列表 */
function getListSearch() {
    loading1.value = true;
    getAllList(queryParamsSearch.value).then(response => {
        dataSearchList.value = response.data.disposeManagers ? response.data.disposeManagers : [];
        total1.value = response.data.total;
        loading1.value = false;
    });
}

// 多选框选中数据
function handleSelectionChange(selection) {
    ids.value = selection.map(item => item.dmId);
    single.value = selection.length != 1;
    multiple.value = !selection.length;
}
function handleSelectionChange1(selection) {
    ids1.value = selection.map(item => item.dmId);
    single1.value = selection.length != 1;
    multiple1.value = !selection.length;
}

/** 删除按钮操作 */
function handleDelete(row) {
    const id = row.dmId || ids.value;
    proxy.$modal.confirm('是否确认删除选中的数据项?').then(function () {
        return delDisposeManager(id);
    }).then(() => {
        getList();
        proxy.$modal.msgSuccess("删除成功");
    }).catch(() => { });
}

function getList1(){
    getPreData(queryParams1.value).then(res=>{
        dataList1.value = res.data?res.data:[];
        total2.value = dataList1.value.length;
    })
}

function handleCurrentChange(value){
    queryParams1.value.page = value;
}

// 打开预案
function handlePreplan(){
    openPre.value = true;
    resetQuery1();
}

/** 搜索按钮操作 */
function handleQuery1() {
    getList1();
}

/** 重置按钮操作 */
function resetQuery1() {
    queryParams1.value = {
        page: 1,
        jepCode: undefined,
        unitname: undefined,
        record: undefined,
        member: undefined,
    },
    proxy.resetForm("queryRef1");
    handleQuery1();
}

// 下载正文
function handleDowonPre(){
    proxy.download("/base/jcEmergcyPlan/export", {...dataList1.value[queryParams1.value.page-1]}, '地震应急预案.xls');
}

// 提交
function handleSubmit() {
    submitPoint(ids.value).then(res => {
        getList();
        proxy.$modal.msgSuccess("提交成功");
    })
}
// 选择
function select() {
    const query = {
        iaId: queryParams.value.id,
        ids: ids1.value
    }
    saveDisposeList(query).then(res => {
        getList();
        proxy.$refs["selectDm"].clearSelection();
        proxy.$modal.confirm('已添加，是否继续查询?').then(function () {
            // return openSearch.value = false;
        }).catch(() => {
            openSearch.value = false;
        });
    })
}
// 打开查询
function handleSearch() {
    getListSearch();
    openSearch.value = true;
    nextTick(() => {
        proxy.$refs["selectDm"].clearSelection();
    })
}

// 上传 
function handleUpload() {
    isAdd.value = true;
    isDetail.value = false;
    proxy.resetForm("czydRef");
    open.value = true;
}

function submitForm() {
    const query = { ...form.value, labelId: tagFormId.value, subtitleId: subTagFormId.value, iaId: queryParams.value.id }
    proxy.$refs["czydRef"].validate(valid => {
        if (valid) {
            if (isAdd.value) {
                saveDisposeManager(query).then(res => {
                    getList();
                    proxy.$modal.msgSuccess("上传成功");
                    open.value = false;
                })
            } else {
                updateDisposeFX(query).then(res => {
                    getList();
                    proxy.$modal.msgSuccess("修改成功");
                    open.value = false;
                })
            }
        }
    })
}

// 添加标签
function handleAddTag() {
    saveTag({ label: dmLabel.value }).then(res => {
        getTag();
        proxy.$modal.msgSuccess("添加成功");
    })
}
function handleAddSubTag() {
    saveSubTag({ subtitle: dmSubLabel.value }).then(res => {
        getSubTag();
        proxy.$modal.msgSuccess("添加成功");
    })
}
// 取消标签管理
function cancelTag() {
    dmLabel.value = undefined;
    openTagManage.value = false;
}
function cancelSubTag() {
    dmSubLabel.value = undefined;
    openSubTagManage.value = false;
}
// 删除
function deleteTag(row) {
    delTag(row.id).then(res => {
        getTag();
        proxy.$modal.msgSuccess("删除成功");
    })
}
function deleteSubTag(row) {
    delSubTag(row.id).then(res => {
        getSubTag();
        proxy.$modal.msgSuccess("删除成功");
    })
}
// 修改
function handleEdit(row) {
    isAdd.value = false;
    isDetail.value = false;
    proxy.resetForm("czydRef");
    handleDetail(row.dmId)
    open.value = true;
}

// 查看
function handleView(row) {
    isAdd.value = false;
    isDetail.value = true;
    proxy.resetForm("czydRef");
    handleDetail(row.dmId)
    open.value = true;
}

// 查
function handleDetail(id) {
    getDisposeManager(id).then(res => {
        form.value = {
            dmType: res.data.dmType,
            dmLabel: res.data.dmLabel,
            dmSubtitle: res.data.dmSubtitle,
            disasterRisk: res.data.disasterRisk,
            disposalPoint: res.data.disposalPoint,
            dmId: res.data.dmId,
        };
        tagFormId.value = res.data.labelId;
        subTagFormId.value = res.data.subtitleId;
    })
}

const formData = ref({
    page:1,
    rows:10,
    label:undefined
})
const formData1 = ref({
    page:1,
    rows:10,
    subtitle:undefined
})
const total3 = ref(0);
const total4 = ref(0);
const isGl = ref(false);
const isSubGl = ref(false);
function handleTag(num) {
    if(num==1) {
        isGl.value = true
    }else{
        isGl.value = false
    };
    formData.value = {
        page:1,
        rows:10,
        label:undefined
    }
    getTag();
    openTagManage.value = true;
    tagLable.value = undefined;
    tagId.value = undefined;
    proxy.$refs['tagRef'].clearSelection();
}
function handleSubTag(num) {
    if(num==1) {
        isSubGl.value = true
    }else{
        isSubGl.value = false
    };
    formData1.value = {
        page:1,
        rows:10,
        subtitle:undefined
    }
    getSubTag();
    openSubTagManage.value = true;
    subTagLable.value = undefined;
    subTagId.value = undefined;
    proxy.$refs['tagSubRef'].clearSelection();
}
function selectTag(selection,row){
    proxy.$refs['tagRef'].clearSelection();
    if(selection.length==0) return
    proxy.$refs['tagRef'].toggleRowSelection(row, true);
}

function selectionChange(val){
    tagLable.value = val.length>0?val[0].label:undefined;
    tagId.value = val.length>0?val[0].id:undefined;
}

function onSelectAll(){
    proxy.$refs['tagRef'].clearSelection();
}
function onSelectAllSub(){
    proxy.$refs['tagSubRef'].clearSelection();
}
function confirmSelect() {
    form.value.dmLabel = tagLable.value;
    tagFormId.value = tagId.value;
    openTagManage.value = false;
}
function selectSub(selection,row){
    proxy.$refs['tagSubRef'].clearSelection();
    if(selection.length==0) return
    proxy.$refs['tagSubRef'].toggleRowSelection(row, true);
}

function selectionChangeSub(val){
    subTagLable.value = val.length>0?val[0].subtitle:undefined;
    subTagId.value = val.length>0?val[0].id:undefined;
}

function confirmSubSelect() {
    form.value.dmSubtitle = subTagLable.value;
    subTagFormId.value = subTagId.value;
    openSubTagManage.value = false;
}

function getTag() {
    getAllTag(formData.value).then(res => {
        tagList.value = res.data.rows ? res.data.rows : [];
        total3.value = res.data.total;
    })
}
function resetTag(){
    formData.value.label = undefined;
    formData.value.page = 1;
    getTag();
}
function getSubTag() {
    getAllSubTag(formData1.value).then(res => {
        subTagList.value = res.data.rows ? res.data.rows : [];
        total4.value = res.data.total;
    })
}
function resetSubTag(){
    formData1.value.subtitle = undefined;
    formData1.value.page = 1;
    getSubTag()
}

// 监听单选按钮
watch(showIcon, (val) => {
    console.log(val);
    showOption.value = val;
    if (showOption.value) {
        getTimeSetCookieFun(`pointsAnalysisCookie${route.query.id}`)
    }
})

// 获取日期时间
function getTimeSetCookieFun(name) {
    var day = getCookieFun(name) == '' ? '' : getCookieFun(name);
    if (day == '') {
        // console.log('没有cookie,说明过期或者还没有存')
        showOption.value = true;
    } else {
        var newTime = new Date().getDate();
        if (newTime > day) {
            // console.log('我是新的一天,我要弹窗')
            showOption.value = true;
        } else {
            showOption.value = false;
        }
    }
}
// 取消商会意见
function cancelOption() {
    showOption.value = false;
}
// // 确认不再提示
function ok() {
    var newTime = new Date().getDate();
    setcookieTimeFun(`pointsAnalysisCookie${route.query.id}`, newTime, 1)
    showOption.value = false;
}
function getOpinion() {
  getImport(route.query.id).then(res => {
    titleOption.value = res.data.importantActivity.iaOpinion;
    showIcon.value = Boolean(Number(res.data.importantActivity.iaOpinionStatus));
    fileNoticeName.value = res.data.list[0].attachName;
    fileNoticeId.value = res.data.list[0].attachId;
  })
}
getOpinion();
getList();
</script>
<style lang="scss" scoped>
.container {
    margin: 0px auto;
    height: 100%;
    width: 1200px;
    overflow-x: hidden;
    overflow-y: auto;

    .worrning {
        width: 340px;
        height: 110px;
        color: #3d4a5d;
        font-size: 18px;
        line-height: 26px;
        background: #f5f9fe;
        margin: 30px auto 10px;
        padding: 15px;
    }

    .header {
        padding: 10px 0px;

        .title {
            font-size: 18px;
            font-weight: bold;
        }

        div {
            height: 60px;
            line-height: 60px;
            margin-top: 10px;

            &.icon {
                padding: 0 20px;
                background: #f5f9fe;
            }
        }
    }
}

.active {
    color: #107ce5;
}

.updateActiveStyles {
    pointer-events: none;
}

:deep(.el-radio-group) {
    display: flex;
    align-items: flex-start;
    flex-direction: column;
}

.ulList {
  li {
    line-height: 30px;
  }

  li::marker {
    color: #F56C6C;
    font-size: 25px;
  }
}

:deep(.pagination-container){
    position: relative;
}
</style>
  